# global gservern, textilenum
gservern = 1

# 纱线支数从前端数据读入
textilenum = 32
num_cotton = 12

import pymysql

# 打开数据库连接
db = pymysql.connect("172.16.34.71", "root", "HUAyuan123456!!!", "icds_api")

# 使用cursor()方法获取操作游标
cursor = db.cursor()

sql = """
SELECT
DATA_INPUT.Yarn_count,
DATA_INPUT.Cotton_variety_count
FROM
DATA_INPUT
ORDER BY
DATA_INPUT.Id DESC
LIMIT 1
"""

try:
    # 执行SQL语句
    cursor.execute(sql)
    # 获取所有记录列表
    data = cursor.fetchone()
    Yarn_count = data[0]
    Cotton_variety_count = data[1]
#    print(Yarn_count)
#    print(Cotton_variety_count)


except Exception as e:
    print("Error: unable to fetch data", e )

restartnn=False
if(restartnn == False):
   textilenum = Yarn_count
#   print('textilenum = ', textilenum)
   num_cotton = Cotton_variety_count
#   print('num_cotton = ', num_cotton)


# 关闭数据库连接
db.close()

# ddof=1  # coefficient of variation model
ddof = 0
# Network parameters
n_hidden1 = 30
# n_hidden2 = 30 # just for test
n_hidden2 = 20
n_hidden3 = 20
n_hidden4 = 20
n_hidden5 = 20
n_hidden6 = 20

n_input = 13
n_output = 5

# Learning Parameters
# eta= 0.00005
eta = 0.0
nepoch = 2000
# nepoch=20
batch_size = 20
display_step = 1
